

/*
 * @(#)ListFormMonitoringDetailAction.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.form.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.dcivision.form.bean.FormRecord;
import com.dcivision.form.dao.FormRecordDAObject;
import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.SystemFunctionConstant;
import com.dcivision.framework.Utility;
import com.dcivision.framework.web.AbstractListAction;
import com.dcivision.framework.web.AbstractSearchForm;

/**
  ListFormMonitoringDetailAction.java

  This class is for list form Monitoring detail

    @author          Tony Chen
    @company         DCIVision Limited
    @creation date   16/01/2003
    @version         $Revision: 1.13.2.2 $
*/

public class ListFormMonitoringDetailAction extends AbstractListAction {

  public static final String REVISION = "$Revision: 1.13.2.2 $";

  protected String listName = "";
  public ListFormMonitoringDetailAction() {
    super();
    this.setListName("formMonitoringDetailList");
    this.setListFunctionName("getFormSubmissionListBySearchSectionForMonitoring");
  }

  /**
   * getMajorDAOClassName
   *
   * @return  The class name of the major DAObject will be used in this action.
   */
  public String getMajorDAOClassName() {
    return("com.dcivision.form.dao.FormSubmissionDAObject");
  }

  /**
   * getFunctionCode
   *
   * @return  The corresponding system function code of action.
   */
  public String getFunctionCode() {
    return(SystemFunctionConstant.FORM_MONITOR);
  }

  /**
   * setPageTitle
   * set the extend page title and page path.
   * default page path/title will be created by navmode and functionCode
   */
  public void setPageTitle(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping, ActionForward actionForward){
    FormRecord formRecord = (FormRecord)request.getAttribute("formRecord");
    if(!Utility.isEmpty(formRecord)){
      String extendTitle=formRecord.getTitle();
      StringBuffer extendPath = new StringBuffer();
      extendPath.append("<a href=\"ListFormMonitoring.do?formGroupID="+formRecord.getFormGroupID());
      extendPath.append("&opMode=");
      extendPath.append(GlobalConstant.OP_MODE_LIST_RETAIN);
      extendPath.append("\">");
      extendPath.append(formRecord.getGroupName());
      extendPath.append("</a>");
      request.setAttribute(GlobalConstant.EXTEND_PAGE_TITLE, extendTitle);
      request.setAttribute(GlobalConstant.EXTEND_PAGE_TITLE_SHOW_ONLY, new Boolean(true));
      request.setAttribute(GlobalConstant.EXTEND_PAGE_PATH, extendPath.toString());
    }
  }

  public ActionForward execute(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response)
       throws ServletException {
     HttpSession session = request.getSession();
     AbstractSearchForm searchForm = (AbstractSearchForm)form;
     String opMode = searchForm.getOpMode();
     String navMode = searchForm.getNavMode();
     String formRecordID = request.getParameter("formRecordID");
     String listStatus = request.getParameter("listStatus");

     //Set Page Title
     ListFormSubmissionForm listForm = (ListFormSubmissionForm)form;
     FormRecordDAObject formRecordDAO = new FormRecordDAObject(this.getSessionContainer(request),this.getConnection(request));
     FormRecord formRecord = (FormRecord)formRecordDAO.getByFormRecordID(listForm.getFormRecordID());
     request.setAttribute("formRecord", formRecord);

     if(!Utility.isEmpty(request.getParameter("searchSubmitter"))){
        ((ListFormSubmissionForm)searchForm).setSearchSubmitter(request.getParameter("searchSubmitter"));
     }
     return super.execute(mapping,form,request,response);
   }


}
